let str = 'cdafadfcdsd';
let res = str.split('').reduce((a, b) => (a[b]++ || (a[b] = 1), a), {});
console.log(res);
